const foo: object = function () {}; // []  {}

const bar: { foo: number; baz?: string } = { foo: 123, baz: "123" };

const arr: number[] = [1, 2, 3];
// const arr: string[] = ['foo', 'bar', 'baz'];

function sum(...args: number[]): number {
  return args.reduce((acc, current) => acc + current, 0);
}

console.log(sum(...arr));

// const tuple: [string, number] = ['123', 12, 123]

const obj = {
  foo: "foo",
  bar: 123,
};

// console.log(Object.entries(obj));

const STATUS = {
  SUCCESS: 1,
  FAILED: 0,
  DOING: 2,
};

function fun(a: number, b: string): string {
  return a + b;
}

const fun1: (a: number, b: number) => number = function (
  a: number,
  b: number
): number {
  return a + b;
};

function stringify(value: any): string {
  return JSON.stringify(value);
}

// const nums = [100, 200, 300, 400]

// const res = <number> nums.find(e => e > 0);
// const square = res * res

interface article {
  title: string;
  content: string;
  share?: number;
  readonly summary: string;
}

function printPost(post: article) {
  console.log(post.title);
  console.log(post.content);
  console.log(post.share);
}

interface Caches {
  [prop: string]: string;
}

const a: Caches = {};

a.foo = "foo";
a.bar = "100";

// class Person {
//   // 类的 属性名一定要有初始值，要么在这里，要么在构造器中。
//   public name: string
//   private age: number
//   protected gender: boolean
//   constructor(name: string, age: number){
//     this.name = name;
//     this.age = age;
//     this.gender = true;
//   }
//   sayHi(msg: string): void{
//     console.log(`hello, i am ${this.name}, ${msg}.`);
//   }
// }

// class Student extends Person{
//   private constructor(name: string, age: number){
//     super(name, age)
//   }
//   sayHi(){
//     console.log(`hello, my name is ${this.name}, i am a ${this.gender ? 'boy' : 'girl'}.`);
//   }
//   static create (name: string, age: number){
//     return new Student(name, age)
//   }
// }

interface EatAndRun {
  eat(food: string): void;
  run(distance: number): void;
}

class Person implements EatAndRun {
  eat(food: string): void {
    console.log(`优雅的吃: ${food}`);
  }
  run(distance: number): void {
    console.log(`行走：${distance}`);
  }
}

// class Animal implements EatAndRun{
//   eat(food: string): void{
//     console.log(`咕噜咕噜的吃: ${food}`);
//   }
//   run(distance: number): void{
//     console.log(`爬行：${distance}`);
//   }
// }

abstract class Animal {
  eat(food: string): void {
    console.log(`咕噜咕噜的吃: ${food}`);
  }
  abstract run(distance: number): void;
}

class Dog extends Animal {
  run(distance: number) {
    console.log(`爬行：${distance} 米`);
  }
}

const dog = new Dog();
dog.eat("狗粮");
dog.run(10000);

function createNumberArray(length: number, value: number): number[] {
  return new Array<number>(length).fill(value);
}

console.log(createNumberArray(5, 100));

function createArray<T>(length: number, value: T): T[] {
  return new Array<T>(length).fill(value);
}

console.log(createArray<string>(4, "foo"));










import { camelCase } from "lodash";
const res = camelCase('hello typed')




// var temp = 10;
// if(true){
//   console.log(temp);
//   let temp
// }



